load("@rules_python//python:defs.bzl", "py_library", "py_test")
load("@py_deps_buildkite//:requirements.bzl", ci_require = "requirement")

py_binary(
    name = "bisect_test",
    srcs = ["bisect_test.py"],
    exec_compatible_with = ["//:hermetic_python"],
    deps = [":bisect"],
    data = [":macos_validator"],
)

genrule(
    name = "macos_validator",
    srcs = ["macos_ci.sh"],
    outs = ["macos_validator.sh"],
    cmd = """
        cat $(location macos_ci.sh) > $@
    """,
)

py_library(
    name = "bisect",
    srcs = glob(
        ["*.py"],
        exclude = [
            "test_*.py",
        ],
    ),
    visibility = ["//ci/ray_ci/bisect:__subpackages__"],
    deps = [
        "//ci/ray_ci:ray_ci_lib",
    ],
)

py_test(
    name = "test_bisector",
    size = "small",
    srcs = ["test_bisector.py"],
    exec_compatible_with = ["//:hermetic_python"],
    tags = [
        "ci_unit",
        "team:ci",
    ],
    deps = [
        ":bisect",
        ci_require("pytest"),
    ],
)

py_test(
    name = "test_generic_validator",
    size = "small",
    srcs = ["test_generic_validator.py"],
    exec_compatible_with = ["//:hermetic_python"],
    tags = [
        "ci_unit",
        "team:ci",
    ],
    deps = [
        ":bisect",
        ci_require("pytest"),
    ],
)
